var $ = require;

var path = $('path');
require.paths.unshift(path.join(__dirname, '../..', 'services'));  //add services to require.paths
var matchService = $('matchService');

var vows = $('vows'),
    assert = $('assert');

vows.describe('match service').addBatch({
    'match/unmatch filter with topic':{
        topic: function(){
            var meta = {"industry": ["computer"], "jobtitle": ["dev"], "location": ["Beijing"], "salary": 6000, "type": ["full time"]};
            return {
                provider:'西安交通大学',
                date: new Date(),
                abstract: 'IBM CDL高级程序员',
                link: 'http://www.xjtu.edu.cn',
                meta: JSON.stringify(meta)
            };
        },

        'match filter with topic for every filter condition': function(jobInfo){
            var filter = {"industry": ["computer", "web"], "jobtitle": ["dev", "qa"], "location": ["Shanghai", "Beijing"], "salary": 5000, "type": ["full time", "part time"]};
            assert.isTrue(matchService.match(jobInfo, filter));
        },

        'match filter with topic for some filter is null': function(jobInfo){
            var filter = {"jobtitle": ["dev", "qa"], "location": ["Shanghai", "Beijing"], "salary": 5000, "type": ["full time", "part time"]};
            assert.isTrue(matchService.match(jobInfo, filter));
        },

        'unmatch filter with topic for some filter is not satified': function(jobInfo){
            var filter = {"industry": ["service"], "jobtitle": ["dev", "qa"], "location": ["Shanghai", "Beijing"], "salary": 5000, "type": ["full time", "part time"]};
            assert.isTrue(matchService.match(jobInfo, filter));
        },

        'unmatch filter with topic for some filter is not in topic': function(jobInfo){
            var filter = {"additional filter": "additional filter", "industry": ["computer"], "jobtitle": ["dev", "qa"], "location": ["Shanghai", "Beijing"], "salary": 5000, "type": ["full time", "part time"]};
            assert.isTrue(matchService.match(jobInfo, filter));
        }
    }
}).export(module);
